package ar.com.cooker.services.util;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5Checksum {
	
	
	
	public static String getMD5CheckSum(String text){
	
		byte[] bytesOfMessage;
		try {
			bytesOfMessage = text.getBytes("UTF-8");
		} catch (UnsupportedEncodingException e) {			
			e.printStackTrace();
			return "";
		}
		MessageDigest md = null;
		try {
			md = MessageDigest.getInstance("MD5");
		} catch (NoSuchAlgorithmException e) {			
			e.printStackTrace();
			return "";
		}
		byte[] thedigest = md.digest(bytesOfMessage);
		StringBuilder result = new StringBuilder("");

		for (int i = 0; i < thedigest.length; i++) {
			result.append(Integer.toString((thedigest[i] & 0xff) + 0x100, 16)
					.substring(1));
		}
		return result.toString();
	}

}
